<template>
	<div>
		<div class="registermain">
			<div class="registimg"></div>
			<div class="registcon">
				<div class="sameregist">
					<i class="sameregimg userimg"></i>
					<input type="text" class="sameinput" placeholder="请输入手机号" ref="phone">
				</div>
				<div class="sameregist" style="display: none;">
					<i class="sameregimg userimg"></i>
					<input type="text" class="sameinput" placeholder="请输入手机号" maxlength="11">
				</div>
				<div class="sameregist">
					<i class="sameregimg verfimg"></i>
					<input type="password" class="sameinput" placeholder="请输入密码" ref="passwords">
				</div>
				<div class="bottomcon">
					<span class="notefont">短信快捷登录</span>
					<span class="forgetpass" @click="forgetbut">忘记密码</span>
				</div>
				<div class="registbut" @click="loginbut">登录</div>
				<div class="accountnum">没有账号？<a class="registfonts" @click="registerbut">免费注册</a></div>
			</div>
		</div>

	</div>
</template>

<script>
	import { BaseUrl } from '../Baseurl/common.js';
	import { gzhUrl } from '../Baseurl/common.js';
	export default {
		data() {
			return {
				listjson:[],
				backUrl:''
				
			}
		},
		created() {

		},
		methods: {
			loginbut:function(){
				var phone = this.$refs.phone.value;
				var pwd = this.$refs.passwords.value;
				this.backUrl = localStorage.getItem('backUrl')
				var url = BaseUrl+'/login/in?phone='+phone+'&pwd='+pwd+'&appId=gzh';
				this.$http.get(url).then(res => {
				
					this.listjson = res.data.data;
					if(res.data.code == "10000"){
						localStorage.setItem('token', this.listjson.token);
						
						var opidurl = BaseUrl+'gzh/isHaveOpenid?token='+this.listjson.token+'&appId=gzh';
						this.$http.get(opidurl).then(res => {
							/*console.log(res.data);
							*/
							if(res.data.data == "none"){
								alert(this.backUrl)
								window.location.href = gzhUrl + '/Uc/author?token='+this.listjson.token+'&appId=gzh&backUrl='+this.backUrl;

							}else{
								this.$router.push({ path: '/goodsDetail' })
							}
							
						})
						//
						//console.log(this.listjson.token);
					}else{
						alert(res.data.msg);
					}

				})
			},
			forgetbut:function(){
				
				this.$router.push({ path: '/forgetpwd_step1'})
			},
			registerbut:function(){
				this.$router.push({ path: '/register'})
			}
			
		}
	}
</script>

<style scoped="scoped">
	.registermain {
		width: 100%;
	}
	
	.registimg {
		width: 100%;
		height: 4.8rem;
		background: red;
	}
	
	.registcon {
		padding: 0.3rem;
		background-color: #fff;
	}
	
	.sameregist {
		width: 100%;
		height: 0.9rem;
		border-bottom: solid 0.01rem #CCCCCC;
	}
	
	.sameregimg {
		width: 0.28rem;
		height: 0.27rem;
		display: inline-block;
		background-color: red;
		margin-top: 0.25rem;
		position: relative;
		top: 0.1rem;
	}
	
	.sameinput {
		width: 80%;
		height: 0.7rem;
		line-height: 0.7rem;
		outline: none;
		color: #323232;
		font-size: 0.28rem;
		margin-left: 0.2rem;
		display: inline-block;
	}
	
	.verfcode {
		width: 60%;
	}
	
	.userimg {
		background: url(../assets/personicon.png);
		background-size: 100%;
	}
	
	.verfimg {
		background: url(../assets/lockicon.png);
		background-size: 100% 100%;
	}
	
	.verification1 {
		width: 0.8rem;
		height: 0.4rem;
		line-height: 0.4rem;
	}
	/******验证码******/
	
	.verfibut {
		padding: 0.03rem 0.1rem;
		border: solid 0.01rem #FF2040;
		display: inline-block;
		float: right;
		margin-top: 0.2rem;
		text-align: center;
		color: #ff2040;
	}
	
	.registbut {
		width: 100%;
		height: 0.8rem;
		background-color: #FF2040;
		border-radius: 0.4rem;
		color: #FFFFFF;
		text-align: center;
		font-size: 0.32rem;
		line-height: 0.8rem;
		margin-top: 0.5rem;
		margin-bottom: 0.25rem;
	}
	.notefont{
		display: inline-block;
		line-height: 0.5rem;
		font-size: 0.2rem;
		color: #989898;
		margin-top: 0.1rem;
	}
	.forgetpass{
		display: inline-block;
		float: right;
		line-height: 0.5rem;
		font-size: 0.2rem;
		color: #989898;
		margin-top: 0.1rem;
	}
	.accountnum{
		text-align: center;
	}
	.accountnum>a{
		color: #FF2040;
		margin-left: 0.02rem;
		text-decoration: underline;
	}
</style>